package com.leetcode.LC;

import java.util.ArrayList;
import java.util.List;

public class LC1408 {
    public List<String> stringMatching(String[] words) {
        //除了自己还被其它字符串包含
        ArrayList<String> list = new ArrayList<>();
        for (int i = 0; i < words.length; i++) {
            String str = words[i];
            for (String word : words) {
                if (!word.equals(str) && word.contains(str) && !list.contains(str)) {
                    list.add(str);
                }
            }
        }
        return list;
    }

    public static void main(String[] args) {
        for (String s : new LC1408().stringMatching(new String[]{"leetcoder", "leetcode", "od", "hamlet", "am"})) {
            System.out.print(s + ",");
        }
    }
}
